package com.example.xpagedemoproject;

import android.os.Bundle;
import android.view.View;

import com.example.xpagedemoproject.fragment.TabAFragment;
import com.example.xpagedemoproject.fragment.TabBFragment;
import com.example.xpagedemoproject1.R;
import com.xuexiang.xpage.base.XPageActivity;
import com.xuexiang.xutil.app.FragmentUtils;
import com.xuexiang.xutil.tip.ToastUtils;

import butterknife.ButterKnife;
import butterknife.OnClick;

public class ComplexActivity extends XPageActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ButterKnife.bind(this);
        changePage(TabAFragment.class,null);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_complex;
    }

    @OnClick({R.id.btn_1,R.id.btn_2,R.id.btn_3,R.id.btn_4})
    protected void onViewClicked(View view){
        switch (view.getId()) {
            case R.id.btn_1:
                changePage(TabAFragment.class);
                break;
            case R.id.btn_2:
                changePage(TabBFragment.class);
                break;
            case R.id.btn_3:
                TabAFragment tabAFragment = getPage(TabAFragment.class);
                if (tabAFragment != null) {
                    ToastUtils.toast(tabAFragment.getData());
                }else{
                    ToastUtils.toast("TabAFragment页面未加载");
                }
                break;
            case R.id.btn_4:
                TabBFragment tabBFragment = getPage(TabBFragment.class);
                if (tabBFragment != null) {
                    ToastUtils.toast(tabBFragment.getData());
                }else{
                    ToastUtils.toast("TabBFragment页面未加载");
                }
                break;
            default:
                break;
        }
    }
}
